﻿<UserControl x:Class="JayDev.MediaScribe.View.Controls.NavigationButton"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:effect="clr-namespace:GrayscaleEffect;assembly=GrayscaleEffect"
             xmlns:nmControls="clr-namespace:JayDev.MediaScribe.View.Controls"
             mc:Ignorable="d" 
             x:Name="NavigationButtonName"
             d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
    <Style x:Key="ChangeMyFonts" TargetType="{x:Type TextBlock}">
        <Setter Property="FontSize" Value="11" />
            <Setter Property="Foreground" Value="#FF3F3F3F" />
        </Style>


        <ControlTemplate x:Key="buttonTemplateWithNoWhiteBorder" TargetType="ButtonBase" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:mwt="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
            <nmControls:CustomButtonChrome Background="{TemplateBinding Panel.Background}" BorderBrush="{TemplateBinding Border.BorderBrush}" RenderDefaulted="{TemplateBinding Button.IsDefaulted}" RenderMouseOver="{TemplateBinding UIElement.IsMouseOver}" RenderPressed="{TemplateBinding ButtonBase.IsPressed}" x:Name="Chrome" SnapsToDevicePixels="True">
                <ContentPresenter RecognizesAccessKey="True" Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" Margin="{TemplateBinding Control.Padding}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
            </nmControls:CustomButtonChrome>
            <ControlTemplate.Triggers>
                <Trigger Property="UIElement.IsKeyboardFocused">
                    <Setter Property="mwt:ButtonChrome.RenderDefaulted" TargetName="Chrome">
                        <Setter.Value>
                            <s:Boolean>True</s:Boolean>
                        </Setter.Value>
                    </Setter>
                    <Trigger.Value>
                        <s:Boolean>True</s:Boolean>
                    </Trigger.Value>
                </Trigger>
                <Trigger Property="ToggleButton.IsChecked">
                    <Setter Property="mwt:ButtonChrome.RenderPressed" TargetName="Chrome">
                        <Setter.Value>
                            <s:Boolean>True</s:Boolean>
                        </Setter.Value>
                    </Setter>
                    <Trigger.Value>
                        <s:Boolean>True</s:Boolean>
                    </Trigger.Value>
                </Trigger>
                <Trigger Property="UIElement.IsEnabled">
                    <Setter Property="TextElement.Foreground">
                        <Setter.Value>
                            <SolidColorBrush>#FFADADAD</SolidColorBrush>
                        </Setter.Value>
                    </Setter>
                    <Trigger.Value>
                        <s:Boolean>False</s:Boolean>
                    </Trigger.Value>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>

    </UserControl.Resources>
    <Grid VerticalAlignment="Stretch">
        <Button x:Name="myButton" Template="{StaticResource buttonTemplateWithNoWhiteBorder}" Background="Transparent" BorderThickness="0" BorderBrush="Transparent" Command="{Binding ElementName=NavigationButtonName, Path=Command}" CommandParameter="{Binding ElementName=NavigationButtonName, Path=CommandParameter}">
            <Button.Style>
                <Style TargetType="{x:Type Button}">
                    <Style.Triggers>
                        <Trigger Property="Control.IsEnabled" Value="false">
                            <Setter Property="Control.Opacity" Value="0.5" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
            <StackPanel>
                <Image x:Name="myImage" Source="{Binding ElementName=NavigationButtonName, Path=MySource, Mode=TwoWay}" Height="16" Width="16">
                    <Image.Effect>
                        <effect:GrayscaleEffect DesaturationFactor="{Binding ElementName=myButton, Path=IsEnabled}"/>
                    </Image.Effect>
                </Image>
                <!--<TextBlock Style="{StaticResource ChangeMyFonts}" Margin="0 5 0 0" HorizontalAlignment="Center" TextAlignment="Center" Text="{Binding ElementName=NavigationButtonName, Path=Text}" LineHeight="8pt" LineStackingStrategy="BlockLineHeight" TextOptions.TextFormattingMode="Display" />-->
            </StackPanel>
        </Button>
    </Grid>
</UserControl>
